package com.demo.component;

import com.demo.model.User;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * Created by IntelliJ IDEA.
 * User: zm
 * Date: 2023/2/26
 */
@Component
public class Users {
    //把对象存入到Spring中
    @Scope("prototype") //设置对象的作用域
    @Bean(name = "u1")
    public User User1(){
        User user = new User();
        user.setId(1);
        user.setName("张三");
        return user;
    }
}
